package com.gsk.europepharma.salesReport.utils;

public class UtilsSalesReport {
	
	public static double arrondir(double in, int decimal) {
		double v = ((Math.round(in * (Math.pow(10, decimal)))) / (Math.pow(10, decimal)));
		return v;
	}
	
	public static double getDeltaPm(double vol, double vol_1, double vol_tt, double vol_tt_1, Integer i) {
		double d = UtilsSalesReport.arrondir(100 * (vol / vol_tt) - 100 * (vol_1 / vol_tt_1), i);
		return d;
	}

	public static double getPm(double vol, double vol_tt, Integer i) {
		double d = UtilsSalesReport.arrondir(100 * (vol / vol_tt), i);
		return d;
	}
	
	public static double getMarche(double vol_tt, Integer i) {
		double d = UtilsSalesReport.arrondir(vol_tt, i);
		return d;
	}

	public static double getVol(double vol, Integer i) {
		double d = UtilsSalesReport.arrondir(vol, i);
		return d;
	}
	
	public static double getDeltaVol(double vol, double vol_1, Integer i) {
		double d = UtilsSalesReport.arrondir(vol - vol_1, i);
		return d;
	}
	
	public static double getEvolVol(double vol, double vol_1, Integer i) {
		double d = UtilsSalesReport.arrondir(100 * ((vol - vol_1) / vol_1), i);
		return d;
	}
	
	public static double getIndicateur(String indicateur, double vol, double vol_1, double vol_tt, double vol_tt_1, Integer i) {
		if (indicateur.equals("PM")) {
			return getPm(vol, vol_tt, i);
		} else if (indicateur.equals("D_PM")) {
			return getDeltaPm(vol, vol_1, vol_tt, vol_tt_1, i);
		} else if (indicateur.equals("VOL")) {
			return getVol(vol, i);
		} else if (indicateur.equals("D_VOL")) {
			return getDeltaVol(vol, vol_1, i);
		} else if (indicateur.equals("EVOL_VOL")) {
			return getEvolVol(vol, vol_1, i);
		}
		return 0.0;
	}
}
